/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.actions.problemas;

import com.mapping.Sla;
import com.mapping.Ticket;
import com.opensymphony.xwork2.ActionSupport;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.EntityTransaction;
import javax.persistence.Persistence;
import javax.persistence.Query;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.Result;

/**
 *
 * @author Andres
 */
@Namespace(value = "/")
@Action(value = "mostrarAltaSolucion", results = {@Result(name = "success", location = "/GestionProblemas/mostrarAltaSolucion.jsp")})
public class MostrarAltaSolucionAction extends ActionSupport{
    private String idTicket;
    private Ticket ticket;
    private List<Sla> listaSlas;
    @Override
    public String execute(){
        EntityManagerFactory emf = Persistence.createEntityManagerFactory("inventarios");
        EntityManager em = emf.createEntityManager();
        EntityTransaction tx = em.getTransaction();
        tx.begin();
            ticket = em.getReference(Ticket.class, idTicket);
            listaSlas = em.createNamedQuery("Sla.findAll").getResultList();
        tx.commit();
        em.close();
        return SUCCESS;
    }

    public Ticket getTicket() {
        return ticket;
    }

    public void setIdTicket(String idTicket) {
        this.idTicket = idTicket;
    }

    public List<Sla> getListaSlas() {
        return listaSlas;
    }

}
